package com.hivekion.system.controller;

import com.hivekion.common.annotation.AutoLog;
import com.hivekion.common.entity.PagedResultVo;
import com.hivekion.common.enums.OperationTypeEnum;
import com.hivekion.system.domain.vo.operationlog.SysOperationLogModelVo;
import com.hivekion.system.domain.vo.operationlog.SysOperationLogSearchPageInputVo;
import com.hivekion.system.domain.vo.operationlog.SysOperationLogViewVo;
import com.hivekion.system.service.ISysOperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/log")
public class SysOperationLogController {

    @Autowired
    ISysOperationLogService service;

    @DeleteMapping("/remove")
    @PreAuthorize("@Permission.hasPermi('cf:sys:log:remove')")
    @AutoLog(value = "操作日志删除", operationType = OperationTypeEnum.DELETE, module = "系统管理/操作日志")
    public boolean remove(String operId) {
        return service.remove(operId);
    }

    @DeleteMapping("/clean")
    @PreAuthorize("@Permission.hasPermi('cf:sys:log:clean')")
    @AutoLog(value = "操作日志清空", operationType = OperationTypeEnum.CLEAN, module = "系统管理/操作日志")
    public boolean clean() {
        service.cleanOperationLog();
        return true;
    }

    @GetMapping("/list")
    public PagedResultVo<SysOperationLogViewVo> list(SysOperationLogSearchPageInputVo inputVo) {
        return service.list(inputVo);
    }

    @GetMapping("/getInfo")
    public SysOperationLogModelVo getInfo(String id) {
        return service.getInfo(id);
    }
}
